package cn.bugstack.springframework.support;


import cn.bugstack.springframework.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tyh1
 * hi 单例bean 的 添加和获取
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    private final Map<String, Object> singletonBeanMap = new HashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return singletonBeanMap.get(beanName);
    }

    protected void addSingleton(String beanName, Object singletonBean) {
        singletonBeanMap.put(beanName, singletonBean);
    }
}